// 呼吸效果进度条（透明度动画）
import QtQuick 2.15

Item {
    id: root
    
    property real value: 0
    property real minimum: 0
    property real maximum: 100
    property real progress: Math.max(0, Math.min(1, (value - minimum) / (maximum - minimum)))
    
    property color startColor: "#2B4AFF"
    property color endColor: "#FF42D5"
    property color backgroundColor: "#FFFFFF"
    property real backgroundOpacity: 0.2
    
    property real animationAlpha: 255
    
    SequentialAnimation on animationAlpha {
        running: true
        loops: Animation.Infinite
        NumberAnimation {
            from: 255
            to: 50
            duration: 1000
            easing.type: Easing.InOutQuad
        }
        NumberAnimation {
            from: 50
            to: 255
            duration: 1000
            easing.type: Easing.InOutQuad
        }
    }
    
    Rectangle {
        id: background
        anchors.fill: parent
        radius: height / 2
        color: backgroundColor
        opacity: backgroundOpacity
    }
    
    Rectangle {
        id: progressBar
        anchors.left: parent.left
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        width: parent.width * progress
        radius: height / 2
        clip: true
        opacity: animationAlpha / 255.0
        
        // 使用渐变（从左往右）
        gradient: Gradient {
            orientation: Gradient.Horizontal  // 水平方向（从左往右）
            GradientStop { position: 0.0; color: startColor }
            GradientStop { position: 1.0; color: endColor }
        }
    }
}

